package loveATM.atm.Panel;

import loveATM.atm.ATM;
import loveATM.atm.Font.MyFont;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * 取款
 */
public class GetPanel extends JPanel implements ActionListener {
    private ATM atm;
    MyFont myFont = new MyFont();
    private JLabel inputLabel = new JLabel("请输入取款金额:");
    private JTextField inputTextField = new JTextField();

    private JButton clearBtn = new JButton(new ImageIcon("images/buttonClear.jpg"));
    private JButton sureBtn = new JButton(new ImageIcon("images/buttonSure.jpg"));
    private JButton offBtn = new JButton(new ImageIcon("images/buttonOff.jpg"));

    public GetPanel(ATM atm){
        this.atm = atm;
        this.setLayout(null);
        this.setOpaque(false);

        inputLabel.setBounds(205,220,200,50);
        inputLabel.setFont(myFont.font);
        this.add(inputLabel);

        inputTextField.setBounds(400,220,250,50);
        inputTextField.setFont(myFont.font);
        this.add(inputTextField);


        clearBtn.setBounds(1024-190,150,140,50);
        clearBtn.addActionListener(this);
        this.add(clearBtn);

        sureBtn.setBounds(1024-190,300,140,50);
        sureBtn.addActionListener(this);
        this.add(sureBtn);

        offBtn.setBounds(1024-190,450,140,50);
        offBtn.addActionListener(this);
        this.add(offBtn);
    }



    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == clearBtn){
            inputTextField.setText("");
        }else if (e.getSource() == offBtn){
            atm.showPanel("menu");
        }else if (e.getSource() == sureBtn){
            atm.showPanel("menu");
        }
    }
}
